package com.yida.gwj.scene.expend.controller;

import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.yida.common.core.utils.poi.ExcelUtil;
import com.yida.common.core.web.controller.BaseController;
import com.yida.common.core.web.domain.AjaxResult;
import com.yida.common.core.web.page.TableDataInfo;
import com.yida.common.log.annotation.Log;
import com.yida.common.log.enums.BusinessType;
import com.yida.common.security.annotation.RequiresPermissions;
import com.yida.gwj.scene.expend.domain.GwjSceneExpendBusiness;
import com.yida.gwj.scene.expend.service.IGwjSceneExpendBusinessService;

/**
 * 坑爹支出老业务业务信息Controller
 * 
 * @author hmh
 * @date 2023-08-14
 */
@RestController
@RequestMapping("/business")
public class GwjSceneExpendBusinessController extends BaseController {
    @Autowired
    private IGwjSceneExpendBusinessService gwjSceneExpendBusinessService;

    /**
     * 查询坑爹支出老业务业务信息列表
     */
    @RequiresPermissions("gwj:scene:expend:business:list")
    @GetMapping("/list")
    public TableDataInfo list(GwjSceneExpendBusiness gwjSceneExpendBusiness) {
        startPage();
        List<GwjSceneExpendBusiness> list = gwjSceneExpendBusinessService.selectGwjSceneExpendBusinessList(gwjSceneExpendBusiness);
        return getDataTable(list);
    }

    /**
     * 导出坑爹支出老业务业务信息列表
     */
    @RequiresPermissions("gwj:scene:expend:business:export")
    @Log(title = "线下支出", businessType = BusinessType.EXPORT, systemName = "gwj")
    @PostMapping("/export")
    public void export(HttpServletResponse response, GwjSceneExpendBusiness gwjSceneExpendBusiness) {
        List<GwjSceneExpendBusiness> list = gwjSceneExpendBusinessService.selectGwjSceneExpendBusinessList(gwjSceneExpendBusiness);
        ExcelUtil<GwjSceneExpendBusiness> util = new ExcelUtil<GwjSceneExpendBusiness>(GwjSceneExpendBusiness.class);
        util.exportExcel(response, list, "坑爹支出老业务业务信息数据");
    }

    /**
     * 获取坑爹支出老业务业务信息详细信息
     */
    @RequiresPermissions("gwj:scene:expend:business:query")
    @GetMapping(value = "/{bizId}")
    public AjaxResult getInfo(@PathVariable("bizId") Long bizId) {
        return AjaxResult.success(gwjSceneExpendBusinessService.selectGwjSceneExpendBusinessByBizId(bizId));
    }

    /**
     * 新增坑爹支出老业务业务信息
     */
    @RequiresPermissions("gwj:scene:expend:business:add")
    @Log(title = "线下支出", businessType = BusinessType.INSERT, systemName = "gwj")
    @PostMapping
    public AjaxResult add(@RequestBody GwjSceneExpendBusiness gwjSceneExpendBusiness) {
        return toAjax(gwjSceneExpendBusinessService.insertGwjSceneExpendBusiness(gwjSceneExpendBusiness));
    }

    /**
     * 修改坑爹支出老业务业务信息
     */
    @RequiresPermissions("gwj:scene:expend:business:edit")
    @Log(title = "线下支出", businessType = BusinessType.UPDATE, systemName = "gwj")
    @PutMapping
    public AjaxResult edit(@RequestBody GwjSceneExpendBusiness gwjSceneExpendBusiness) {
        return toAjax(gwjSceneExpendBusinessService.updateGwjSceneExpendBusiness(gwjSceneExpendBusiness));
    }

    /**
     * 删除坑爹支出老业务业务信息
     */
    @RequiresPermissions("gwj:scene:expend:business:remove")
    @Log(title = "线下支出", businessType = BusinessType.DELETE, systemName = "gwj")
    @DeleteMapping("/{bizIds}")
    public AjaxResult remove(@PathVariable Long[] bizIds) {
        return toAjax(gwjSceneExpendBusinessService.deleteGwjSceneExpendBusinessByBizIds(bizIds));
    }
}
